package org.teremail.schema;

/**
 * Dialect interface used to handle the difference between various databases.
 *  
 * @author Michael Barker
 */
public interface Dialect {

    
    /**
     * Return the string used in for an integer value in a create statement.
     * 
     * @param precision
     * @return
     */
    String getInteger(int precision);

    /**
     * Return the string used in for a varchar value in a create statement.
     * 
     * @param precision
     * @return
     */
    String getVarchar(int length);

    /**
     * Returns a column type that has a time and date component.
     * 
     * @return
     */
    String getTimestamp();

    String generateBinary(int length);

    String getBlob();
    
    String getTableName(String tableName);

    boolean isDuplicateKey(String state);

    /**
     * Determines if this database can page results in SQL.  If this returns
     * false, the sql code should page the results from the query itself.
     * 
     * @return
     */
    boolean isPagingSupported();

    /**
     * Creates a paged queries for the given parameters.  Will inline the
     * page values directly into the query.  This should be safe (no injection)
     * as the page values are typed as ints.
     * 
     * @param columns
     * @param tables
     * @param constraints
     * @param orderBy
     * @param pageNo
     * @param pageSize
     * @return
     */
    String createPagedQuery(String columns, String tables, String constraints,
            String orderBy, int pageNo, int pageSize);

}
